﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;


public partial class AdminManage_Edit_GPEdit : System.Web.UI.Page
{

    public string gpid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        gpid = Request["gpid"];
        bind();
    }


    private void bind()
    {
        GPInfo gpquery = new GPInfo();
        int GPID = Convert.ToInt32(gpid);
        DataSet ds = gpquery.SelectByGPID(GPID);
        DataRowView dv = ds.Tables[0].DefaultView[0];

        
        
      
        ZL_FILE_ID.Text = Convert.ToString(dv.Row["ZL_FILE_ID"]);


        GP_NAME.Text = Convert.ToString(dv.Row["GP_NAME"]);
        GP_CODE.Text = Convert.ToString(dv.Row["GP_CODE"]);
        PM_PATH_NAME.Text = Convert.ToString(dv.Row["PM_PATH_NAME"]);
        PM_PATH_NUM.Text = Convert.ToString(dv.Row["PM_PATH_NUM"]);



        FEATURE.InnerText = Convert.ToString(dv.Row["FEATURE"]);
        DESCRIB.InnerText = Convert.ToString(dv.Row["DESCRIB"]);
        IMAGE.Text = Convert.ToString(dv.Row["IMAGE"]);
        JD_NAME.Text = Convert.ToString(dv.Row["JD_NAME"]);

        JGGZ.Text = Convert.ToString(dv.Row["JGGZ"]);
        JD_PEOPLE.Text = Convert.ToString(dv.Row["JD_PEOPLE"]);

        JD_DATE.Text = Convert.ToString(dv.Row["JD_DATE"]);



        LR_PEOPLE.Text = Convert.ToString(dv.Row["LR_PEOPLE"]);
        LR_DATE.Text = Convert.ToString(dv.Row["LR_DATE"]);
 

        //从著录表中读取title
        ZLInfo ZLFILEID = new ZLInfo();
        ZL_TBL zl = ZLFILEID.SelectZLInfoByID(dv.Row["ZL_FILE_ID"].ToString());
        TITLE_.Text = zl.O_TITLE;
        FileTitle.Text = zl.O_TITLE;


    }


    protected void submit_Click(object sender, EventArgs e)
    {
        GP_INFO_TBL gpInfo = new GP_INFO_TBL();
        GPInfo kc_in = new GPInfo();

        gpInfo.O_ZL_FILE_ID = Request.Form["ZL_FILE_ID"];

        gpInfo.O_GP_NAME = Request.Form["GP_NAME"];
        gpInfo.O_GP_CODE = Request.Form["GP_CODE"];


        gpInfo.O_PM_PATH_NAME = Request.Form["PM_PATH_NAME"];
        gpInfo.O_PM_PATH_NUM = Request.Form["PM_PATH_NUM"];
        gpInfo.O_FEATURE = this.FEATURE.InnerText;
        gpInfo.O_DESCRIB = this.DESCRIB.InnerText;





        //gpInfo.O_IMAGE = Request.Form["IMAGE"];
        gpInfo.O_JD_NAME = Request.Form["JD_NAME"];
        gpInfo.O_JGGZ = Request.Form["JGGZ"];

        gpInfo.O_JD_PEOPLE = Request.Form["JD_PEOPLE"];


        gpInfo.O_JD_DATE = Request.Form["JD_DATE"];

        gpInfo.O_LR_PEOPLE = Request.Form["LR_PEOPLE"];
        gpInfo.O_LR_DATE = Request.Form["LR_DATE"];

        gpInfo.O_ID = int.Parse(gpid);

        if (kc_in.UpdateGPInfo(gpInfo) == 1)
        {
            bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/GPManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/GPManage.aspx'</script>");
        }
    }
}